iT邦幫忙

2023 iThome 鐵人賽

DAY 30
0
自我挑戰組

AI研究系列 第 30

影像辨識實作(五):Kaggle平台實作yolo映像辨識

  • 分享至 

  • xImage
  •  

運行整個程式

Sample images
img_names = ['../input/dog.jpg', '../input/office.jpg']
for img in img_names: display(Image.open(img))
https://ithelp.ithome.com.tw/upload/images/20231010/20162284zcV1E91aj2.png
檢測
使用 IoU(用於非最大壓制的截獲與聯合比率)閾值測試模型

batch_size = len(img_names)
batch = load_images(img_names, model_size=_MODEL_SIZE)
class_names = load_class_names('../input/coco.names')
n_classes = len(class_names)
max_output_size = 10
iou_threshold = 0.5
confidence_threshold = 0.5

model = Yolo_v3(n_classes=n_classes, model_size=_MODEL_SIZE,
max_output_size=max_output_size,
iou_threshold=iou_threshold,
confidence_threshold=confidence_threshold)

inputs = tf.placeholder(tf.float32, [batch_size, 416, 416, 3])

detections = model(inputs, training=False)

model_vars = tf.global_variables(scope='yolo_v3_model')
assign_ops = load_weights(model_vars, '../input/yolov3.weights')

with tf.Session() as sess:
sess.run(assign_ops)
detection_result = sess.run(detections, feed_dict={inputs: batch})

draw_boxes(img_names, detection_result, class_names, _MODEL_SIZE)
https://ithelp.ithome.com.tw/upload/images/20231010/20162284A0t1gmwybF.png


上一篇
影像辨識實作(四):Kaggle平台實作yolo映像辨識
系列文
AI研究30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言